package calorie.com.calorie.contact;

import android.content.Context;

import com.lxh.baselibray.mvp.BasePresent;
import com.lxh.baselibray.mvp.IBaseView;
import com.lxh.baselibray.net.NetCallBack;
import com.lxh.baselibray.net.ServiceGenerator;

import calorie.com.calorie.api.ApiService;
import calorie.com.calorie.request.GoodsListRequest;
import calorie.com.calorie.request.GoodsOrderRequest;
import calorie.com.calorie.response.GoodsListResponce;
import calorie.com.calorie.response.GoodsOrderResponce;
import retrofit2.Call;
import retrofit2.Response;

/**
 * Created by chenxi on 2019/4/11.
 */

public class GoodsOrdersContact {
    public static class GoodsOrdersPresent extends BasePresent<GoodsOrdersContact.IGoodsOrdersView> {
        public void goodsOrders(final Context context, Integer status,Integer pageNo,Integer userId){
            ApiService service = ServiceGenerator.createService(ApiService.class);
            GoodsOrderRequest request = new GoodsOrderRequest(status,pageNo,userId);
            service.goodsOrders(request).enqueue(new NetCallBack<GoodsOrderResponce>() {
                @Override
                public void onSuccess(Call<GoodsOrderResponce> call, Response<GoodsOrderResponce> response) {
                    if(getView()!= null){
                        getView().getGoodsOrdersResult(response);
                    }
                }

                @Override
                public void onFailed() {

                }
            });
        }
    }

    public interface IGoodsOrdersView extends IBaseView {
        void getGoodsOrdersResult(Response<GoodsOrderResponce> response);
    }
}
